package com.fr.report.web.ui;

import com.fr.base.StringUtils;
import com.fr.base.core.ComparatorUtils;
import com.fr.base.core.json.JSONException;
import com.fr.base.core.json.JSONObject;
import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLableReader;
import com.fr.web.Repository;

public class CustomButton extends Button
{
  private String prefix = "x-btn";

  public String getXType()
  {
    return "custombutton";
  }

  public String getPrefix()
  {
    return this.prefix;
  }

  public void setPrefix(String paramString)
  {
    this.prefix = paramString;
  }

  public String[] supportedEvents()
  {
    return new String[] { "afterinit", "click" };
  }

  public JSONObject createJSONConfig(Object paramObject, Repository paramRepository)
    throws JSONException
  {
    JSONObject localJSONObject = super.createJSONConfig(paramObject, paramRepository);
    if (StringUtils.isNotBlank(this.prefix))
      localJSONObject.put("prefix", getPrefix());
    return localJSONObject;
  }

  public void readXML(XMLableReader paramXMLableReader)
  {
    super.readXML(paramXMLableReader);
    if (paramXMLableReader.isChildNode())
    {
      String str2 = paramXMLableReader.getTagName();
      if (str2.equals("Prefix"))
      {
        String str1;
        if ((str1 = paramXMLableReader.getElementValue()) != null)
          setPrefix(str1);
      }
    }
  }

  public void writeXML(XMLPrintWriter paramXMLPrintWriter)
  {
    super.writeXML(paramXMLPrintWriter);
    if ((StringUtils.isNotBlank(this.prefix)) && (!("x-btn".equals(this.prefix))))
      paramXMLPrintWriter.startTAG("Prefix").textNode(this.prefix).end();
  }

  public boolean equals(Object paramObject)
  {
    if ((paramObject == null) || (!(paramObject instanceof CustomButton)))
      return false;
    CustomButton localCustomButton = (CustomButton)paramObject;
    return ((super.equals(paramObject)) && (ComparatorUtils.equals(getPrefix(), localCustomButton.getPrefix())));
  }

  public Object clone()
    throws CloneNotSupportedException
  {
    CustomButton localCustomButton = (CustomButton)super.clone();
    return localCustomButton;
  }
}